package com.wms.utils;

import java.util.Map;
import java.util.Set;

/**
 * @author This
 * @version 1.0
 * @date 2019/7/17 20:51
 */
public class SQLStringUtils {

    public static String toLikeString(Map map, String type, String... except) {
        StringBuffer sb = new StringBuffer();
        Set set = map.keySet();
        if (except != null && except.length > 0) {
            for (String s : except) {
                if (set.contains(s)) {
                    set.remove(s);
                }
            }
        }
        if (set.size() > 0) {
            for (Object o : set) {
                sb.append(type + " " + o + " like '%" + map.get(o) + "%' ");
            }
        }
        return sb.length() > 0 ? sb.toString().substring(type.length()) : null;
    }
}
